package org.sn.jdish.spring.demo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import com.sn.spring.demo.document.Demo;
import com.sn.spring.demo.repository.DemoDao;
import com.sn.spring.demo.vo.DemoVo;

@Service
public class DemoBiz {

	@Autowired
	private DemoDao demoDao;

	@Autowired
	private MongoTemplate mongoTemplate;

	public String sayHello(String name) {
		demoDao.deleteAll();
		Demo demo = new Demo();
		demo.setName(name);
		mongoTemplate.insert(demo);
		System.out.println(demoDao.findAll().get(0).getId());
		return "hello, " + name;
	}

	public String sayHello(DemoVo vo) {
		return "hello, " + vo.getName();
	}

}
